using System.Configuration;
using System.IO;
using System.Web.UI;
using Castle.MonoRail.Framework.Helpers;
using Recaptcha;

namespace AndyPike.Commons.Web.MonoRail.Helpers
{
    public class CaptchaHelper : AbstractHelper
    {
        public string Render()  
        {  
            var captchaControl = new RecaptchaControl {  
                                                          ID = "recaptcha",  
                                                          Theme = "blackglass",
                                                          PublicKey = ConfigurationManager.AppSettings["recaptcha.public"],
                                                          PrivateKey = ConfigurationManager.AppSettings["recaptcha.private"]  
                                                      };  
          
            var htmlWriter = new HtmlTextWriter( new StringWriter() );  
          
            captchaControl.RenderControl(htmlWriter);  
          
            return htmlWriter.InnerWriter.ToString();  
        } 
    }
}